  
var tableManage = function() {

    var _init = function() {
        var table = $('#table_order');
        var  userId = $('#userId').val();
        var tableUnit = table.dataTable({
            "processing": true,
            // 开启服务器模式
            serverSide: true,
            "ajax": {
                url:posturl,
            },
            "autoWidth": true,
            "columns": [
                {"data":"nickName"},
                {"data":"mobile"},                
                {
                    "data": "create_time",//申请日期
                    "render":function(data, type, row, meta) {
                        return moment(data).format('YYYY-MM-DD HH:mm');
                    }
                },
                {
                    "data": "amount",//提现金额
                    "render": function(data, type, row, meta) {
                        if(data){
                            return data/100
                        }else{
                            return "--"
                        }
                    }
                },
                {
                    "data":"accountName"//提现账户
                },
                {
                    "data": "status",//提现状态
                    "render": function(data, type, row, meta) {
                        if(data == '1'){
                            return '已申请';
                        }else if(data == '2'){
                            return "已提现";
                        } else if(data == '3') {
                            return '提现失败'
                        } else {
                            return "--";
                        }
                    }
                },
                {
                    "data":"status",//交易时间,
                    "render":function(data, type, row, meta) {
                        if(row.tradeNo) {
                            return '交易时间：'+row.tradeDate+'交易单号：'+row.tradeNo;
                        } else {
                            return row.causefail;
                        }
                    }
                },
            ],
            "language": {
                url: '/public/static/admin/pages/Chinese.json'
            },
            "pageLength": 10,
            "stateSave": true,
            "stateSaveParams": function (settings, data) {
                var search = data.search.search;
                if(search){
                    var arr = $.parseJSON(search);
                    for(var key in arr){
                        $("#searchForm input[name='"+key+"']").val(arr[key]);
                        $("#searchForm select[name='"+key+"']").val(arr[key]);
                    }
                }
            },
            "order": [
                [2, "desc"]
            ],
            "dom": "<'row'<'.col-md-6 col-sm-12'><'col-md-6 col-sm-12'>r>" +
                "<t>" +
                "<'table_b relative'<'col-md-5'i><'col-md-7'>lp>",
            "fnInitComplete": function() {},           
        });

        //排序搜索
        $('#search .form-control').change(function(event){  //拼团商品排序展示
            var status = $("#search select[name='search']").val();
            var param = {"status":status};
            table.DataTable().search(JSON.stringify(param)).draw();
        });                     
    };

    return {
        init: function() {
            _init();
        }
    };

}();

$(function() {
    tableManage.init();
});